﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RR66Response_v1", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RR66ResponseV1))]
    public class RR66ResponseV1Serializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRR66ResponseV1 clazz;
        
        public RR66ResponseV1Serializer(IRR66ResponseV1 clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("Isikukood");
            if (clazz.Isikukood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikukood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikukood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikupnimi");
            if (clazz.Isikupnimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikupnimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikupnimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikuenimi");
            if (clazz.Isikuenimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikuenimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikuenimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("SurmaKuup");
            if (clazz.SurmaKuup!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.SurmaKuup))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SurmaKuup");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("KodakondsusKood");
            if (clazz.KodakondsusKood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.KodakondsusKood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : KodakondsusKood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("KodakondsusNimetus");
            if (clazz.KodakondsusNimetus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.KodakondsusNimetus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : KodakondsusNimetus");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("EmakeelKood");
            if (clazz.EmakeelKood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.EmakeelKood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : EmakeelKood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("EmakeelNimetus");
            if (clazz.EmakeelNimetus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.EmakeelNimetus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : EmakeelNimetus");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("MkKood");
            if (clazz.MkKood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.MkKood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : MkKood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Maakond");
            if (clazz.Maakond!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Maakond))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Maakond");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("ValdKood");
            if (clazz.ValdKood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ValdKood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : ValdKood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Vald");
            if (clazz.Vald!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Vald))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Vald");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("AsulaKood");
            if (clazz.AsulaKood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AsulaKood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : AsulaKood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Asula");
            if (clazz.Asula!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Asula))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Asula");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Vaikekoht");
            if (clazz.Vaikekoht!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Vaikekoht))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Vaikekoht");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Tanav");
            if (clazz.Tanav!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Tanav))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Tanav");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Nimi");
            if (clazz.Nimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Nimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Nimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Maja");
            if (clazz.Maja!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Maja))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Maja");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Korter");
            if (clazz.Korter!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Korter))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Korter");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("EestkosteOn");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.EestkosteOn))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("ElamislubaOn");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.ElamislubaOn))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("ElamislubaTahtaeg");
            if (clazz.ElamislubaTahtaeg!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ElamislubaTahtaeg))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : ElamislubaTahtaeg");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Veakood");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Veakood))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("Veatekst");
            if (clazz.Veatekst!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Veatekst))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Veatekst");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="Isikukood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>Isikukood");
                }
                clazz.Isikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikukood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>Isikukood", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikupnimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>Isikupnimi");
                }
                clazz.Isikupnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikupnimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>Isikupnimi", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikuenimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>Isikuenimi");
                }
                clazz.Isikuenimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikuenimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>Isikuenimi", Reader.LocalName);
            }
            if (Reader.LocalName=="SurmaKuup") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>SurmaKuup");
                }
                clazz.SurmaKuup = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("SurmaKuup")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>SurmaKuup", Reader.LocalName);
            }
            if (Reader.LocalName=="KodakondsusKood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>KodakondsusKood");
                }
                clazz.KodakondsusKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("KodakondsusKood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>KodakondsusKood", Reader.LocalName);
            }
            if (Reader.LocalName=="KodakondsusNimetus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>KodakondsusNimetus");
                }
                clazz.KodakondsusNimetus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("KodakondsusNimetus")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>KodakondsusNimetus", Reader.LocalName);
            }
            if (Reader.LocalName=="EmakeelKood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>EmakeelKood");
                }
                clazz.EmakeelKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("EmakeelKood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>EmakeelKood", Reader.LocalName);
            }
            if (Reader.LocalName=="EmakeelNimetus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>EmakeelNimetus");
                }
                clazz.EmakeelNimetus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("EmakeelNimetus")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>EmakeelNimetus", Reader.LocalName);
            }
            if (Reader.LocalName=="MkKood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>MkKood");
                }
                clazz.MkKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("MkKood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>MkKood", Reader.LocalName);
            }
            if (Reader.LocalName=="Maakond") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>Maakond");
                }
                clazz.Maakond = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Maakond")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>Maakond", Reader.LocalName);
            }
            if (Reader.LocalName=="ValdKood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>ValdKood");
                }
                clazz.ValdKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ValdKood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>ValdKood", Reader.LocalName);
            }
            if (Reader.LocalName=="Vald") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>Vald");
                }
                clazz.Vald = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Vald")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>Vald", Reader.LocalName);
            }
            if (Reader.LocalName=="AsulaKood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>AsulaKood");
                }
                clazz.AsulaKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("AsulaKood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>AsulaKood", Reader.LocalName);
            }
            if (Reader.LocalName=="Asula") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>Asula");
                }
                clazz.Asula = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Asula")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>Asula", Reader.LocalName);
            }
            if (Reader.LocalName=="Vaikekoht") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>Vaikekoht");
                }
                clazz.Vaikekoht = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Vaikekoht")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>Vaikekoht", Reader.LocalName);
            }
            if (Reader.LocalName=="Tanav") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>Tanav");
                }
                clazz.Tanav = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Tanav")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>Tanav", Reader.LocalName);
            }
            if (Reader.LocalName=="Nimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>Nimi");
                }
                clazz.Nimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Nimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>Nimi", Reader.LocalName);
            }
            if (Reader.LocalName=="Maja") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>Maja");
                }
                clazz.Maja = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Maja")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>Maja", Reader.LocalName);
            }
            if (Reader.LocalName=="Korter") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>Korter");
                }
                clazz.Korter = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Korter")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>Korter", Reader.LocalName);
            }
            if (Reader.LocalName=="EestkosteOn") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>EestkosteOn");
                }
                clazz.EestkosteOn = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("EestkosteOn")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>EestkosteOn", Reader.LocalName);
            }
            if (Reader.LocalName=="ElamislubaOn") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>ElamislubaOn");
                }
                clazz.ElamislubaOn = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("ElamislubaOn")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>ElamislubaOn", Reader.LocalName);
            }
            if (Reader.LocalName=="ElamislubaTahtaeg") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>ElamislubaTahtaeg");
                }
                clazz.ElamislubaTahtaeg = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ElamislubaTahtaeg")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>ElamislubaTahtaeg", Reader.LocalName);
            }
            if (Reader.LocalName=="Veakood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>Veakood");
                }
                clazz.Veakood = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("Veakood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>Veakood", Reader.LocalName);
            }
            if (Reader.LocalName=="Veatekst") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR66Response_v1>Veatekst");
                }
                clazz.Veatekst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Veatekst")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR66Response_v1>Veatekst", Reader.LocalName);
            }
        }
    }
}
